package com.hit.client.biz.autoInit;

import com.hit.client.api.dto.config.RobotBaseProperties;
import com.hit.client.api.dto.config.RobotClientProperties;
import com.hit.client.comm.NettyClient;
import com.hit.client.driver.RobotDriverService;
import com.hit.client.api.dto.service.Send2ServerService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;


@Component
@RequiredArgsConstructor
@Slf4j
public class AppRunner implements CommandLineRunner {

    private final RobotDriverService robotDriverService;

    private final RobotClientProperties clientProperties;

    private final Send2ServerService send2ServerService;

    @Override
    public void run(String... args) {
        log.info("[初始化] 开始");
        //向服务端注册当前执行端
        log.info("[初始化] 向服务端注册当前执行端");
        send2ServerService.registerClient(clientProperties.getBaseInfo());

        //请求服务端各类数据
        log.info("[初始化] 请求服务端各类数据");
        send2ServerService.requestServerData();

        //初始化驱动
        log.info("[初始化] 初始化驱动");
        robotDriverService.init();

        log.info("[初始化] 完成");
    }

}
